#ifndef LOGGER_H
#define LOGGER_H


#include <QtCore>
#include <QDebug>
#include <QSharedPointer>

#include <defs/export.h>
#include <defs/global.h>

#include <log4qt/logger.h>

namespace Opl { namespace Core {

		/*!
		  Exception while logging/initialize Logger class
		  \sa Logger
		  \sa LoggerItem
		  */
		class CORE_EXPORT LoggerException{
		public:
			LoggerException(const QString& reason):what(reason){}
			QString What() { return what; }
		private:
			QString what;
		};

		/*!
		  Logger item object for logging into Logger singleton class
		  \sa Logger
		  */
		class CORE_EXPORT LoggerItem: public QObject, public QDebug {
			Q_OBJECT
			LOG4QT_DECLARE_QCLASS_LOGGER
		public:
			enum Level{
				FATAL	= 0,
				ERR		= 1,
				WARNING = 2,
				INFO	= 3,
				DEBUG	= 4,
				TRACE	= 5
			};

			LoggerItem();
			~LoggerItem();

			LoggerItem& Trace();
			LoggerItem& Debug();
			LoggerItem& Info();
			LoggerItem& Warning();
			LoggerItem& Error();
			LoggerItem& Fatal();

		private:
			Q_DISABLE_COPY(LoggerItem)
			QString buffer;
			Level level;
			friend class Logger;
		};


/*

		O_PRIVATE_DECLARE(Logger);
		class CORE_EXPORT Logger : public QObject {
			Q_OBJECT
			LOG4QT_DECLARE_QCLASS_LOGGER
		public:
			enum Mode{
				append = QFile::Append,
				truncate = QFile::Truncate
			};

			Logger(const QString& filename, LoggerItem::Level level = LoggerItem::INFO, Mode mode = append);
			~Logger();

			static void Initialize(const QString& filename, const QString& level = "INFO", const QString& mode = "APPEND");
			static void Initialize(const QString& filename, LoggerItem::Level level = LoggerItem::INFO, Mode mode = append);
			static Logger& logger();
			void LogMessage(const LoggerItem& msg);

		signals:
				void message(LoggerItem::Level level, QString msg);
		private:
			typedef QSharedPointer<Logger> LoggerPtr;
			static LoggerPtr _loggerPtr;

			Q_DISABLE_COPY(Logger)
			O_PRIVATE_DECLARE_MEMBER(Logger);
		};


*/


}; };



#endif // LOGGER_H

